package com.lagou.controller;

import com.lagou.feign.GoodsFeign;
import com.lagou.pojo.Orders;
import com.lagou.pojo.OrdersVo;
import com.lagou.pojo.Products;
import com.lagou.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @Author : liuchangling
 * @Descrition :
 * @Date： Created in 11:51 上午 2021/9/17
 */
@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrderService orderService;

    @GetMapping("/query/{id}")
    public Orders queryId(@PathVariable Integer id) {
        return orderService.findOrderById(id);
    }

    @PostMapping("/queryPage")
    public Map<String, Object> queryByPage(@RequestBody OrdersVo ordersVo) {
        Map<String, Object> map = orderService.selectPage(ordersVo);
        return map;
    }

    @Autowired
    private GoodsFeign goodsFeign;

    @GetMapping("/product/query/{id}")
    public List<Products> queryGoodsById(@PathVariable Integer id) {
        //调用商品微服务接口
        List<Products> list = goodsFeign.queryGoodsById(id);
        return list;
    }
}
